#ifndef _XOUTPUT_H
#define _XOUTPUT_H

#include <Arduino.h>

class XOutput {
public:
  XOutput(int pin = 2, bool onLevel = false, bool enable = true, void (*delay)(unsigned long) = delay):
    _pin(pin), _onLevel(onLevel), _state(false), _enable(enable), _delay(delay) { }
  XOutput &init(bool state = false);
  XOutput &on(void);
  XOutput &off(void);
  XOutput &hold(unsigned long time, unsigned long timeAfterOff = 0);
  XOutput &setState(bool newState);
  XOutput &reverse(void);
  XOutput &blink(int times = 1, unsigned long holdTime = 50);
  bool getState(void);
  XOutput &enable(void);
  XOutput &disable(void);
private:
  int _pin;
  bool _onLevel, _state, _enable;
  void (*_delay)(unsigned long);
};

#endif // _XOUTPUT_H
